/*
 * Copyright (c) 2017,安徽皖通科技股份有限公司 All rights reserved.
 */

package com.wttech.dzzf.process.service.initilize;

import com.wttech.dzzf.process.dao.DataInitilizingDao;
import com.wttech.dzzf.process.service.base.BaseInfoService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * 数据初始化监控类
 *
 * @author MaShibo
 * @date 2017/12/12.
 */
@Service
public class DataInitilizingMonitor {

	private static final Logger LOGGER = LoggerFactory.getLogger(DataInitilizingMonitor.class);

	private static final String[] TABLES = {"KF_USERINFO", "KF_COMPANYINFO", "AC_USERINFOOPT"};

	@Resource
	private DataInitilizingDao dataInitilizingDao;

	@Resource
	private DataInitilizingService dataInitilizingService;

	@Resource
	private BaseInfoService baseInfoService;

	@Scheduled(fixedDelay = 1000 * 60 * 2)
	public void monitor() {
		if (!dataInitilizingService.isRunning()) {
			return;
		}
		if (LOGGER.isInfoEnabled()){
			int userIdNum = dataInitilizingDao.queryCardInfoUserIdNum();
			LOGGER.info(baseInfoService.buildMonitorMsg(TABLES) +  String.format("%nAC_CARDINFO 中有【%d】条数据存在USERID", userIdNum));
		}
	}


}
